-
Notifications
You must be signed in to change notification settings - Fork 200
Matrix exponential #1038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Matrix exponential #1038
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Updating branch with latest dev from stdlib/main
jalvesz
approved these changes
Oct 7, 2025
jvdp1
reviewed
Oct 7, 2025
Member
jvdp1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @loiseaujc . Overall LGTM. Here are some suggestions
jalvesz
requested changes
Oct 8, 2025
Co-authored-by: Jeremie Vandenplas <[email protected]>
jalvesz
approved these changes
Oct 17, 2025
jvdp1
approved these changes
Oct 17, 2025
Member
jvdp1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think it is ready to be merged! Thank you @loiseaujc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following a comment by Meromorphic on the discourse here, this PR implements the matrix exponential function
expm. It does so in a newstdlib_linalg_matrix_functionssubmodule which might eventually accomodate later on implementations of other matrix functions (e.g.logm,sqrtm,cosm, etc).Proposed interfaces
E = expm(A [, order, err])call matrix_exp(A [, order, err])(in-place)call matrix_exp(A, E [, order, err])(out-of-place)where
Ais the inputn x nmatrix,order(optional) is the order of the Pade approximation, anderrof typelinalg_state_typefor error handling.Key facts
The implementation makes use of a standard "scaling and squaring" approach to compute the Pade approximation with a fixed order. It is adapted from the implementation by John Burkardt.
Progress
Possible improvements
The implementation is fully working and validated. Computational performances and/or robustness could potentially be improved eventually by considering:
orderfor the Pade approximation based on the data. This is used for instance inscipy.linalg.expm.In practice, it has however never failed me so far.
cc @perazz, @jvdp1, @jalvesz
PS : This is actually a re-opening of #968 which was automatically closed when I deleted my own fork of
stdlib(don't ask me why, I can't remember).